<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 100px;
        height: 100px;
        background-color: red;
      }
    </style>
  </head>
  <body>
    <!-- 程序员写代码测试的时候,给标签添加id属性. 现代浏览器会自动帮我们执行下面这个代码: 
        const box = document.getElementById('box')
        不能在上线的代码里面写.因为有些老的浏览器没有这个功能
    -->
    <div class="box" id="box"></div>
    <script>
      // 注意: 这几个事件主要在移动端触发
      box.ontouchstart = function (e) {
        console.log('touchstart', e)
      }
      box.ontouchmove = function (e) {
        console.log('touchmove', e)
      }
      box.ontouchend = function (e) {
        console.log('touchend', e)
      }
      //   box.ontouchcancel = function () {
      //     console.log('touchcancel')
      //   }
    </script>
  </body>
</html>
